{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f555b386",
   "metadata": {},
   "source": [
    "## Loading a pretrained model from TDC-Huggingface Interface\n",
    "For example, we want to load a DeepPurpose model that uses GNN-based AttentiveFP model for Blood brain barrier prediction:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f1d070c6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/json": {
       "ascii": false,
       "bar_format": null,
       "colour": null,
       "elapsed": 0.02356719970703125,
       "initial": 0,
       "n": 0,
       "ncols": null,
       "nrows": 60,
       "postfix": null,
       "prefix": "Downloading",
       "rate": null,
       "total": 7601387,
       "unit": "B",
       "unit_divisor": 1000,
       "unit_scale": true
      },
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "6dd82050541b4ae08379b203b770648a",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Downloading:   0%|          | 0.00/7.60M [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/json": {
       "ascii": false,
       "bar_format": null,
       "colour": null,
       "elapsed": 0.01989889144897461,
       "initial": 0,
       "n": 0,
       "ncols": null,
       "nrows": 60,
       "postfix": null,
       "prefix": "Downloading",
       "rate": null,
       "total": 479,
       "unit": "B",
       "unit_divisor": 1000,
       "unit_scale": true
      },
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "089849b68c424b4aa78cc79395769e80",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Downloading:   0%|          | 0.00/479 [00:00<?, ?B/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING:root:No normalization for BCUT2D_MWHI\n",
      "WARNING:root:No normalization for BCUT2D_MWLOW\n",
      "WARNING:root:No normalization for BCUT2D_CHGHI\n",
      "WARNING:root:No normalization for BCUT2D_CHGLO\n",
      "WARNING:root:No normalization for BCUT2D_LOGPHI\n",
      "WARNING:root:No normalization for BCUT2D_LOGPLOW\n",
      "WARNING:root:No normalization for BCUT2D_MRHI\n",
      "WARNING:root:No normalization for BCUT2D_MRLOW\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Drug Property Prediction Mode...\n",
      "in total: 1 drugs\n",
      "encoding drug...\n",
      "unique drugs: 1\n",
      "do not do train/test split on the data for already splitted data\n",
      "predicting...\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.867601752281189"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from tdc import tdc_hf_interface\n",
    "tdc_hf = tdc_hf_interface(\"BBB_Martins-AttentiveFP\")\n",
    "dp_model = tdc_hf.load_deeppurpose('./data')\n",
    "tdc_hf.predict_deeppurpose(dp_model, ['CC(=O)NC1=CC=C(O)C=C1'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d9a097fd",
   "metadata": {},
   "source": [
    "Note that we are doing testing on the DeepPurpose library. More support to other libraries will be added soon. If you would like to contribute a new library class, please contact us!"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "530f363e",
   "metadata": {},
   "source": [
    "## Uploading a model to TDC-Huggingface Interface\n",
    "For example, we want to upload a model that uses GNN-based AttentiveFP model for Blood brain barrier prediction. The below code will upload it to the [https://huggingface.co/tdc/BBB_Martins-AttentiveFP](https://huggingface.co/tdc/BBB_Martins-AttentiveFP)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ded3d742",
   "metadata": {},
   "outputs": [],
   "source": [
    "from tdc import tdc_hf_interface\n",
    "tdc_hf = tdc_hf_interface(\"BBB_Martins-AttentiveFP\")\n",
    "tdc_hf.upload('./examples/huggingface_examples/BBB_Martins-AttentiveFP')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2243421f",
   "metadata": {},
   "source": [
    "The repo name should be \"TDC official dataset name-Model name\". You can upload any model that you would like. But we request it to be tuned and finalized if you want to be included in the tdc huggingface space. "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
